{extend name="base" /}
{block name="content"}
<div class="content">
    <div class="container-fluid">
        <!-- Page-Title -->
        <div class="row">
            <div class="col-12">
                <div class="page-title-box">
                    <div class="page-title-right">
                        <ol class="breadcrumb m-0">
                            <li class="breadcrumb-item"><a href="{:url('index/index')}"><i class="fe-home"></i> 控制台</a></li>
                            <li class="breadcrumb-item active"> Add Link</li>
                        </ol>
                    </div>
                <h4 class="page-title"> 
                    <button onClick="javascript:history.go(-1)" type="button" class="btn btn-xs btn-secondary waves-effect waves-light">
                            <i class="fe-corner-up-left"></i> 返回
                    </button>
                    Add Link </h4>
                </div>
            </div>
        </div>
        <div class="row">
        <div class="col-lg-8 col-md-6">
            <div class="card-box">
                    <form id="form1">
                    <br/>
                    <div class="form-group row">
                        <label for="user" class="col-2 col-form-label">ICON图标图标</label>
                        <div class="col-8">
                            <input type="text" class="form-control" id="icon" placeholder="fa-calendar-o" name="icon">
                            <code><a href="http://www.fontawesome.com.cn/faicons/" target="_blank">选择图标</a></code>
                            <br/>
                            <xmp><i class="fa fa-calendar-o"></i> </xmp>
                            选择class中的除去[<code>fa</code>]后的名称，如：<code>fa-calendar-o</code>
                        </div>
                        
                    </div>
                    <div class="form-group row">
                        <label for="user" class="col-2 col-form-label">链接URL</label>
                        <div class="col-8">
                            <input type="text" class="form-control" id="url" placeholder="链接" name="url">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="user" class="col-2 col-form-label">链接名称</label>
                        <div class="col-8">
                            <input type="text" class="form-control" id="name" placeholder="链接名称" name="name">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="user" class="col-2 col-form-label">分类排序</label>
                        <div class="col-8">
                            <input type="text" class="form-control" id="sort" placeholder="分类排序" value="50" name="sort">
                        </div>
                    </div>
                    <div class="form-group mb-5 justify-content-end row">
                        <div class="col-10">
                             <a class="btn btn-info waves-effect waves-light" style="color: #fff" data-ids="1" onclick="postBtn(this)" >提交</a>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div> <!-- container -->
</div> <!-- content -->
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(['element', 'form', 'layedit','upload'], function () {
        var form = layui.form;
        var $ = layui.jquery,upload = layui.upload;
    })

    function postBtn(e){
        var data = $('#form1').serialize();
        $.post('/admin/link/add', data, function(res){
            if(res.code == 0){
                layer.msg(res.message,{icon:1, time:1000, shade: [0.2, '#000']});
                setTimeout(function(){
                    window.location.href=res.data.url;
                },1000);
            }else{
                layer.msg(res.message,{icon:5, anim: 6, time:1000, shade: [0.2, '#000']});
            }
        },'json');
    }
</script>
{/block}